var booksArray = [
    { id: 1, title: '西线无战事' },
    { id: 2, title: '新异化的诞生：社会加速批判理论大纲' },
];

localStorage.setItem('book', booksArray) //ok

localStorage.getItem('name') // '[object Object]'

const shopping = [
    { fruits: "apple", quantity:  3},
    { fruits: "watermelon", quantity: 1},
];

const shoppingString = JSON.stringify(shopping);
console.log(shoppingString)
//  [{"fruits":"apple","quantity":3},{"fruits":"watermelon","quantity":1}]

const shoppingString =
    '[{"fruits":"apple","quantity":3},{"fruits":"watermelon","quantity":1}]'

const shopping = JSON.parse(shoppingString);

console.log(shopping); //Array

// 保存读书清单数据函数
function saveToLocalStorage(data) {
    localStorage.setItem('book-list', JSON.stringify(data));
}
